package com.kehao.leetcode.middle.math;


import org.junit.Test;

public class ExcelTitleToNumberSolution {
    public int titleToNumber(String columnTitle) {
        int result = 0;
        char[] charArray = columnTitle.toCharArray();
        for (int i = 0; i < charArray.length; i++) {
            result = result*26+ (charArray[i]-'A'+1);
        }
        return result;
    }

    @Test
    public void test01(){
        System.out.println(titleToNumber("AA"));
    }

    @Test
    public void test02(){
        System.out.println(titleToNumber("AB"));
    }

    @Test
    public void test03(){
        System.out.println(titleToNumber("ZY"));
    }

    @Test
    public void test04(){
        System.out.println(titleToNumber("FXSHRXW"));
    }
}
